Default Android vcpkg builds to Java HTTP#1510
Conversation
Decouple Android HTTP transport choice from MATSDK_USE_VCPKG_DEPS so consumers can use vcpkg-provided native dependencies while still packaging the Java/JNI transport. Files changed: - CMakeLists.txt, lib/CMakeLists.txt, cmake/MSTelemetryConfig.cmake.in: add MATSDK_ANDROID_HTTP_CLIENT and export Android Java source metadata. - tools/ports/cpp-client-telemetry/*, docs/building-with-vcpkg.md: add android-java-http feature, source guard, and consumer documentation. - lib/pal/posix/*_Android.cpp: align initializer order for current NDK Clang builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41
Make Android AUTO select the Java/JNI HTTP transport regardless of dependency sourcing, and require explicit android-curl-* features for native curl. Files changed: - CMakeLists.txt: resolve Android AUTO to JAVA. - tools/ports/cpp-client-telemetry/portfile.cmake: use the in-repo checkout for overlay builds and add explicit Android curl feature handling. - tools/ports/cpp-client-telemetry/vcpkg.json: move Android curl to explicit android-curl-openssl/android-curl-mbedtls features. - docs/building-with-vcpkg.md: document Java default and curl escape hatch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41
There was a problem hiding this comment.
Pull request overview
This pull request updates the Android vcpkg build defaults to use the Java/JNI HTTP transport (instead of implicitly selecting curl based on vcpkg dependency mode), while keeping native curl available as an explicit Android-only escape hatch.
Changes:
- Introduces
MATSDK_ANDROID_HTTP_CLIENT=AUTO|JAVA|CURLand makesAUTOresolve toJAVAon Android, wiring this through both CMake and the vcpkg port. - Splits Android curl selection into explicit vcpkg features (
android-curl-openssl,android-curl-mbedtls) and installs the Java bridge sources for vcpkg consumers when Java transport is selected. - Updates vcpkg documentation and fixes Android PAL constructor initializer ordering to address new
-Werrorwarnings.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/ports/cpp-client-telemetry/vcpkg.json | Adds Android-specific curl override features; refines Linux curl feature platform scoping; keeps defaults oriented to Linux. |
| tools/ports/cpp-client-telemetry/portfile.cmake | Selects MATSDK_ANDROID_HTTP_CLIENT for Android vcpkg builds and validates feature combinations (Linux vs Android curl features). |
| lib/pal/posix/SystemInformationImpl_Android.cpp | Reorders initializer list to match member declaration order (avoids -Wreorder warnings). |
| lib/pal/posix/NetworkInformationImpl_Android.cpp | Reorders initializer list for -Wreorder (and touches Android network cost initialization). |
| lib/pal/posix/DeviceInformationImpl_Android.cpp | Reorders initializer list for -Wreorder. |
| lib/CMakeLists.txt | Switches Android source selection between HttpClient_Android and curl based on the resolved Android transport; installs Java bridge sources for vcpkg Java transport. |
| docs/building-with-vcpkg.md | Documents Android Java default, curl escape hatch, installed Java bridge source location, and AndroidX annotation dependency. |
| CMakeLists.txt | Adds the MATSDK_ANDROID_HTTP_CLIENT option, resolves AUTO to JAVA on Android, and updates curl-need logic to depend on the resolved Android transport. |
| cmake/MSTelemetryConfig.cmake.in | Exports Android HTTP transport metadata and Java source directory from the installed CMake package config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| NetworkInformationImpl::NetworkInformationImpl(IRuntimeConfig& configuration) : | ||
| m_info_helper(), | ||
| m_cost(NetworkCost_Unknown), | ||
| m_info_helper(), | ||
| m_isNetDetectEnabled(configuration[CFG_BOOL_ENABLE_NET_DETECT]){}; |
There was a problem hiding this comment.
| DeviceInformationImpl::DeviceInformationImpl(IRuntimeConfig& configuration) : | ||
| m_info_helper(), | ||
| m_powerSource(PowerSource_Battery) | ||
| m_powerSource(PowerSource_Battery), | ||
| m_info_helper() | ||
| {} |
| set(MSTelemetry_ANDROID_HTTP_CLIENT "@MATSDK_ANDROID_HTTP_CLIENT_RESOLVED@") | ||
| set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR | ||
| "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_DATADIR@/cpp-client-telemetry/android/java") | ||
|
|
There was a problem hiding this comment.
NetworkInformationImpl_Android.cpp: initialize m_registeredCount so callback registration bookkeeping does not read an indeterminate value. Verified m_registeredCount is incremented/decremented in lib/pal/NetworkInformationImpl.hpp. DeviceInformationImpl_Android.cpp: initialize m_registeredCount for the same callback bookkeeping path. Verified m_registeredCount is incremented/decremented in lib/pal/DeviceInformationImpl.hpp. MSTelemetryConfig.cmake.in: update the curl dependency comment to reflect Linux, explicit Android curl builds, and macOS-without-Apple-HTTP only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
lib/pal/posix/NetworkInformationImpl_Android.cpp:47
NetworkInformationImplleavesm_registeredCount(andm_type) uninitialized. Because the base class inline Register/Unregister methods increment/decrementm_registeredCountandGetNetworkType()returnsm_type, this is undefined behavior on Android builds.
NetworkInformationImpl::NetworkInformationImpl(IRuntimeConfig& configuration) :
m_cost(NetworkCost_Unknown),
m_info_helper(),
m_registeredCount(0),
lib/pal/posix/DeviceInformationImpl_Android.cpp:57
DeviceInformationImplleavesm_os_architectureandm_registeredCountuninitialized.GetOsArchitectureType()returnsm_os_architecturedirectly and the inline Register/Unregister callback methods updatem_registeredCount, so this is undefined behavior on Android.
DeviceInformationImpl::DeviceInformationImpl(IRuntimeConfig& configuration) :
m_powerSource(PowerSource_Battery),
m_info_helper(),
m_registeredCount(0)
| elseif(EXISTS "${CURRENT_PORT_DIR}/../../../CMakeLists.txt") | ||
| get_filename_component(SOURCE_PATH "${CURRENT_PORT_DIR}/../../.." ABSOLUTE) | ||
| message(STATUS "cpp-client-telemetry: building in-repo overlay source ${SOURCE_PATH}") |
There was a problem hiding this comment.
Fixed in 5982520. The in-repo overlay detection now requires SDK-specific paths (CMakeLists.txt, lib/CMakeLists.txt, and tools/ports/cpp-client-telemetry/portfile.cmake) before treating ../../../ as the SDK checkout; otherwise it falls back to the pinned release path. See tools/ports/cpp-client-telemetry/portfile.cmake:17-28. No further change needed for this thread.
| set(MSTelemetry_ANDROID_HTTP_CLIENT "@MATSDK_ANDROID_HTTP_CLIENT_RESOLVED@") | ||
| set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR | ||
| "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_DATADIR@/cpp-client-telemetry/android/java") | ||
|
|
There was a problem hiding this comment.
Fixed in 5982520. MSTelemetry_ANDROID_JAVA_SOURCE_DIR is now populated only when MSTelemetry_ANDROID_HTTP_CLIENT is JAVA; otherwise it is set to an empty string. See cmake/MSTelemetryConfig.cmake.in:31-37. No further change needed for this thread.
portfile.cmake: make in-repo overlay source detection require SDK-specific paths so registry/vcpkg checkouts cannot be mistaken for cpp_client_telemetry. MSTelemetryConfig.cmake.in: set MSTelemetry_ANDROID_JAVA_SOURCE_DIR only for Java-transport packages; set it empty otherwise. Android PAL: initialize m_type and m_os_architecture alongside the callback counters so inline getters never read indeterminate values. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41
| message(FATAL_ERROR | ||
| "curl-openssl (default) and curl-mbedtls are mutually exclusive but both were " | ||
| "selected. To use mbedTLS, drop the defaults with the [core,...] form and " | ||
| "re-select a SQLite backend (the [core,...] form also drops the default " | ||
| "system-sqlite feature), e.g. " | ||
| "cpp-client-telemetry[core,curl-mbedtls,system-sqlite] " | ||
| "(or minimal-sqlite in place of system-sqlite).") | ||
| elseif(_matsdk_http_feature_count EQUAL 0) | ||
| "The curl HTTP backend features are mutually exclusive but multiple were " | ||
| "selected. On Linux, use exactly one of curl-openssl/curl-mbedtls. On " | ||
| "Android, use exactly one of android-curl-openssl/android-curl-mbedtls.") |
| set(MSTelemetry_ANDROID_HTTP_CLIENT "@MATSDK_ANDROID_HTTP_CLIENT_RESOLVED@") | ||
| if(MSTelemetry_ANDROID_HTTP_CLIENT STREQUAL "JAVA") | ||
| set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR | ||
| "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_DATADIR@/cpp-client-telemetry/android/java") | ||
| else() | ||
| set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR "") | ||
| endif() |
Problem
Android vcpkg builds should not use
MATSDK_USE_VCPKG_DEPSto decide the HTTP transport. Dependency sourcing and transport selection are separate concerns.Android apps already package Java/JNI integration for platform context, device/system/network/power state, cache path, and lifecycle. The Android Java HTTP bridge is therefore the right default transport. Native curl is still useful as an explicit escape hatch for unusual native-only Android consumers.
Changes
MATSDK_ANDROID_HTTP_CLIENT=AUTO|JAVA|CURL.AUTOnow resolves toJAVA.CURLremains available as an explicit override.HttpClient_Androidinstead of curl.android-curl-opensslandroid-curl-mbedtlsHttpClient.javaHttpClientRequest.java-Werror.Validation
vcpkg install cpp-client-telemetry[core,system-sqlite] --triplet arm64-android --overlay-ports=tools/portsMATSDK_ANDROID_HTTP_CLIENT=AUTOconfigured successfully.vcpkg install cpp-client-telemetry[core,android-curl-openssl,system-sqlite] --triplet arm64-android --overlay-ports=tools/portsMATSDK_ANDROID_HTTP_CLIENT=CURL.vcpkg format-manifest tools/ports/cpp-client-telemetry/vcpkg.jsonNote
The in-repo overlay port now builds the checkout source by default. When publishing this feature to the registry, bump the port
REF/SHA512to a release that containsMATSDK_ANDROID_HTTP_CLIENT.